//
//  WBTitleView.m
//  TransWB
//
//  Created by 孝飞王 on 2017/1/12.
//  Copyright © 2017年 孝飞王. All rights reserved.
//

#import "WBTitleView.h"

@implementation WBTitleView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        NSString *title = @"首页";
        if([WBNetworkManager shareManager].userAccount.screen_name){
            
            [self setImage:[UIImage imageNamed:@"navigationbar_arrow_down"] forState:UIControlStateNormal];
            [self setImage:[UIImage imageNamed:@"navigationbar_arrow_up"] forState:UIControlStateSelected];
            title = [NSString stringWithFormat:@"%@ ",[WBNetworkManager shareManager].userAccount.screen_name];
        }
        
        [self setTitle:title forState:UIControlStateNormal];
        
        self.titleLabel.font = [UIFont boldSystemFontOfSize:17];
       // [self.titleLabel setTextColor:[UIColor blackColor]];
       // [self.titleLabel setTintColor:[UIColor darkGrayColor]];
        [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [self setTitleColor:[UIColor darkGrayColor] forState:UIControlStateHighlighted];

        // 3> 设置大小
        [self sizeToFit];

    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    if([WBNetworkManager shareManager].userAccount.screen_name){
        
        self.titleLabel.frame = CGRectOffset(self.titleLabel.bounds, 0, 0);
        self.imageView.frame = CGRectOffset(self.imageView.bounds, self.titleLabel.bounds.size.width, self.titleLabel.frame.size.height/2 - self.imageView.frame.size.height/2 );
    }

}

@end
